import http from '../utils/axios';

const baseUrl = 'http://dsq.ljc.icu:8080'
// const baseUrl = 'http://172.16.110.131:8080/'


////////////订单信息===============================================================
//获取所有订单信息
interface getData {
    state: number,
    pageNum: number,
    size: number
}

export const getOrderAll = (params: getData) =>
    http.get<any>(baseUrl + '/order/selecByState', params)

// 管理员根据订单状态查询所有订单
interface getQuery {
    orderId?: number | undefined;
    orderState?: number,
    size?: number,
    page?: number,
    userPhone?: string,
    orderCreated?: string | undefined,
}
export const getOrderByCondition = (data: getQuery) =>
    http.post<any>(baseUrl + '/order/selecByCondition', data)

// 根据订单编号查询订单详情信息
interface selectId {
    orderId: number,
}
export const getOrderDetailById = (params: selectId) =>
    http.get<any>(baseUrl + '/order/selectByOrderId', params)


// 根据订单编号确认订单
interface confirmId {
    orderId: number,
}
export const confirmOrderById = (params: confirmId) =>
    http.post<any>(baseUrl + '/order/confimOrder', params)

//根据订单编号修改联系人信息 
export const setUserInfoByOrder = (data: any) =>
    http.post<any>(baseUrl + '/order/updateByOrderId', data)


// 根据订单编号关闭订单
interface closeId {
    orderId: number,
}
export const closeOrderById = (params: closeId) =>
    http.post<any>(baseUrl + '/order/closeOrder', params)


// 根据商品id和订单编号查询商品规格信息
export const getGoodsById = (data: any) =>
    http.post<any>(baseUrl + '/order/selectByGoodsVo', data)

// 根据商品规格id和商品数量进行更新订单信息
export const setOrderBySku = (data: any) =>
    http.post<any>(baseUrl + '/order/updateBySku', data)

// 根据订单编号设置订单
export const setOrderTime = (data: any) =>
    http.post<any>(baseUrl + '/order/orderSetTime', data)


////////////////退款信息============================================================
//获取所有退款、退货订单信息
interface getRefundAll {
    state?: number | string,
    salesType?: number,
    pageNum: number,
    size: number,
}
export const getRefundAll = (data: getRefundAll) =>
    http.get<any>(baseUrl + '/aftermarket/selectAll', data)


//获取退款订单信息详情
interface getOrderId {
    orderId: number,
}
export const getOrderRefundById = (data: getOrderId) =>
    http.get<any>(baseUrl + '/aftermarket/selectAftermarketByOrderId', data)



// 管理员处理售后情况
export const setRefundRes = (data: any) =>
    http.post<any>(baseUrl + '/aftermarket/insertHandlingOpinions', data)


//管理员根据条件筛选售后列表
// interface selectcontion{
//     marketNum?:string,
//     marketState:number,
//     marketTime?: string,
//     orderId?:number,
//     page:number,
//     salesType:number
// }


export const selectCondition = (data: any) =>
    http.post<any>(baseUrl + '/aftermarket/selectCondition', data)



// //获取退换货所有数据
// interface selectAllReason{
//     pageNum:number,
// 	size:number,
// }
// export const selectAllReason = (data: selectAllReason) => 
//     (http.get<any>(baseUrl+'/aftereason/selectAllReason',data))


//////////////////////////////退换原因
// 退换原因设置==================================================================
interface getAllReason {
    pageNum: number,
    size: number,
}
export const getAllReason = (params: getAllReason) =>
    http.get<any>(baseUrl + '/aftereason/selectAllReason', params)


//管理员删除退换原因
interface oppId {
    appliId?: number,
}
export const delReason = (data: any | oppId) =>
    http.post<any>(baseUrl + '/aftereason/deleteAftereasonList', data)

//管理员修改退换原因
export const updateReason = (data: any) =>
    http.post<any>(baseUrl + '/aftereason/updateAftereason', data)

// 管理员添加退换原因
interface getDataAdmin {
    insertTime: string;
    startUse: number;
    reasonDescription: string | undefined;
}
export const addReason = (data: getDataAdmin) =>
    http.post<any>(baseUrl + '/aftereason/InsertAftereason', data)




//管理员修改退换原因启用状态
// interface update{
//     orderId:number,
//     startUse:boolean | number,
// }
export const updateCondition = (data: any) =>
    http.post<any>(baseUrl + '/aftereason/updateStateList', data)



/////////////////////////订单设置=======================================================
//获取订单设置初始值
export const selectorderSetTime = (params: any) =>
http.get<any>(baseUrl + '/order/selectOrderSetting', params)



//修改订单设置初始值
export const orderSetTime = (data: any) =>
    http.post<any>(baseUrl + '/order/orderSetTime', data)

